package com.atgugu.springcloud.service.impl;

import com.atgugu.springcloud.dao.StorageDao;
import com.atgugu.springcloud.service.StorageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.StopWatch;

import javax.annotation.Resource;

/**
 * @author ZhangXinWang
 * @date 2023/1/7 20:56
 */
@Service
@Slf4j
public class StorageServiceImpl implements StorageService {

    @Resource
    private StorageDao storageDao;

    @Override
    public void decrease(Long productId, Integer count) {
        StopWatch stopWatch = new StopWatch("库存微服务");
        stopWatch.start("开始扣减库存");
        storageDao.decrease(productId, count);
        stopWatch.stop();
        log.info(stopWatch.prettyPrint());
    }

}
